package fang;

import java.util.Random;

public class Demo04 {

	public static void main(String[] args) {
		Random random=new Random();
		int[]a=new int[10];
		for (int i = 0; i < a.length; i++) {
			a[i]=random.nextInt(10)+1;
		}
		int max = a[0];
		int mix = a[0];	
		int maxIndex=0;
		int mixIndex=0;
		
		for (int i = 0; i < a.length; i++) {
			if (max<a[i]) {
				max=a[i];
				maxIndex = i;
			}
			if (mix>a[i]) {
				mix = a[i];
				mixIndex = i;
			}
		}
		
		int temp = a[0];
		a[0] = max;
		a[maxIndex] = temp;
		
		temp = a[a.length-1];
		a[a.length-1] = mix;
		a[mixIndex] = temp;
		for (int i = 0; i < a.length; i++) {
			System.out.println(a[i]);
		}
	}
	

}
